package com.leo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 * @ClassName SplitPaneDemo
 * @Description
 * @Author wangss
 * @date 2020.05.26 14:48
 * @Version 1.0
 */
public class SplitPaneDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane anchorPane = new AnchorPane();
        anchorPane.setStyle("-fx-background-color: #e7eeea");
        Scene scene = new Scene(anchorPane);

        SplitPane splitPane = new SplitPane();
        splitPane.setPrefWidth(600d);

        Button button1 = new Button("button1");
        Button button2 = new Button("button2");
        Button button3 = new Button("button3");
        Button button4 = new Button("button4");

        StackPane sp1 = new StackPane();
        sp1.getChildren().add(button1);

        StackPane sp2 = new StackPane();
        sp2.getChildren().add(button2);

        StackPane sp3 = new StackPane();
        sp3.getChildren().add(button3);

        StackPane sp4 = new StackPane();
        sp4.getChildren().add(button4);

        splitPane.getItems().addAll(sp1, sp2, sp3, sp4);

        // 这里的平分规则要注意
        splitPane.setDividerPositions(0.25, 0.5, 0.75, 1.0);

        AnchorPane.setLeftAnchor(splitPane, 10d);
        anchorPane.getChildren().add(splitPane);

        primaryStage.setScene(scene);
        primaryStage.setTitle("combobox");
        primaryStage.setWidth(625d);
        primaryStage.setHeight(500d);
        primaryStage.setResizable(false);
        primaryStage.show();
    }
}
